/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.note.service;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.note.entity.Note;
import com.thinkgem.jeesite.modules.note.dao.NoteDao;

/**
 * 笔记增删改查Service
 * @author liyutg
 * @version 2017-07-26
 */
@Service
@Transactional(readOnly = true)
public class NoteService extends CrudService<NoteDao, Note>  {
	
	public Note get(String id) {Note note = super.get(id);return note;}
	
	public List<Note> findList(Note note) {
		return super.findList(note);
	}
	
	public Page<Note> findPage(Page<Note> page, Note note) {
		return super.findPage(page, note);
	}
	
	@Transactional(readOnly = false)
	public void save(Note note) {
		super.save(note);
	}
	
	@Transactional(readOnly = false)
	public void delete(Note note) {
		super.delete(note);
	}

	@Transactional(readOnly = false)
	public void insertNote(String noteType, String noteTimeCreate, String noteTimeUpdate,
						   String noteTitle, String noteText, String noteUserId){
		dao.insertNote1(noteType,noteTimeCreate,noteTimeUpdate,noteTitle,noteText,noteUserId);
	}
	/**
	 *根据标题查找笔记id
	 */
	public String search(String title,String user_id){
		return dao.search(title,user_id);
	}
	/**
	 *查找最新笔记id
	 */
	public String getNoteId(String userId){
		return dao.getNoteId1(userId);
	}
	/**
	 *根据笔记id查找用户id
	 */
	public String getUserId(String noteId){
		return dao.getUserId(noteId);
	}
	/**
	 *更新笔记
	 */
	@Transactional(readOnly = false)
	public void updateNote(String userId,String noteId,String title,String text,String noteTimeUpdate){
		 dao.updateNote(userId,noteId,title,text,noteTimeUpdate);
	}
	/**
	 *根据笔记id，用户id 更改笔记类型
	 */
	@Transactional(readOnly = false)
	public void updateNoteType(String type,String userId,String noteId){
		dao.updateNoteType(type,userId,noteId);
	}
	/**
	 *根据用户id及类型找到对应笔记
	 */
	public List<Note> noteList(String userId, String type, String style){
		return dao.noteList(userId,type,style);
	}
	/**
	 *根据用户id找对应笔记
	 */
	public Note getNote(String noteId){
		return dao.getNote(noteId);
	}

	/**
	 *根据列，内容删除对应笔记 type列名称 content 内容
	 */
	@Transactional(readOnly = false)
	public void deleteNote(String type,String content,String userId){
		dao.deleteNote(type,content,userId);
	}


}